<template>
    <div class="container yuan-container">

        <a-card title="系统日志">
            <div class="table">
                <a-table bordered :loading="loading" :rowKey="(item,i)=>item.id" :columns="columns" :data-source="pageList"
                    :pagination="pagination">
                    <template slot='action' slot-scope="text, record, index"></template>
                </a-table>
            </div>
        </a-card>
    </div>
</template>
<script lang="ts">
import api from "@/api/api";
import { Component, Vue } from "vue-property-decorator";
@Component({
    name: "tpl",
    components: { },
})
export default class extends Vue {
    loading = false;
    pageList = [];
    pagination = {
        current: 1,
        pageSize: 10,
        total: 0,
        onChange: this.pageChange,
    };
    columns = [
        {
            title: "序号",
            dataIndex: "index",
            key: "index",
            align: "center",
            customRender: (text: string, record: any, index: number) => `${index + 1}`,
        },
        {
            align: "center",
            dataIndex: "operator",
            key: "operator",
            title: "操作人",
        },
        {
            align: "center",
            dataIndex: "executeTime",
            key: "executeTime",
            title: "操作时间",
        },
        {
            align: "center",
            dataIndex: "content",
            key: "content",
            title: "操作内容",
        },
    ];
    async getList() {
        this.pageList = [];
        this.loading = true;
        try {
            const res = await api.getSystemLog({
                pageNum: this.pagination.current,
                pageSize: this.pagination.pageSize,
            });
            this.pageList = res.data?.rows || [];
            this.pagination.total = res.data?.total || 0;
        } finally {
            this.loading = false;
        }
    }
    resetList() {
        this.pagination.current = 1;
        this.getList();
    }
    pageChange(page: number, pageSize: number) {
        this.pagination.pageSize = pageSize;
        this.pagination.current = page;
        this.getList();
    }

    mounted() {
        this.getList();
    }
}
</script>
<style scoped lang="scss">
.container {
}
</style>
